package com.example.wan_android.http

import com.example.wan_android.http.bean.AuthorNameResponseData
import com.example.wan_android.http.bean.AuthorResponseData
import com.example.wan_android.http.bean.BannerResponse
import com.example.wan_android.http.bean.CollectionResponseData
import com.example.wan_android.http.bean.FriendResultData
import com.example.wan_android.http.bean.HotWordListData
import com.example.wan_android.http.bean.KnowledgeBodyResponse
import com.example.wan_android.http.bean.NavResponeData
import com.example.wan_android.http.bean.PaperApiResponse
import com.example.wan_android.http.bean.ProjectCategoryData
import com.example.wan_android.http.bean.ProjectContentResponseData
import com.example.wan_android.http.bean.SearchResponseData
import com.example.wan_android.http.bean.SystemResponeData
import com.example.wan_android.http.bean.UserResponseData
import com.example.wan_android.model.CommenCodeData
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

interface ApiService {
    @GET("/article/list/{index}/json")
    suspend fun getPapers(
        @Path("index") index: Int // 路径参数
    ): retrofit2.Response<PaperApiResponse>

    @GET("banner/json")
    suspend fun getBanners(): retrofit2.Response<BannerResponse>

    @GET("/friend/json")
    suspend fun getFriends(): retrofit2.Response<FriendResultData>

    @GET("/hotkey/json")
    suspend fun getHotWords(): retrofit2.Response<HotWordListData>

    @GET("/tree/json")
    suspend fun getSystems(): retrofit2.Response<SystemResponeData>

    @GET("/navi/json")
    suspend fun getNavItems(): retrofit2.Response<NavResponeData>

    @GET("/article/list/{index}/json")
    suspend fun getKnowledgeBodyData(
        @Path("index") index: Int,
        @Query("cid") cid: Int // 使用 @Query 明确指定查询参数
    ): retrofit2.Response<KnowledgeBodyResponse>


    @GET("/project/tree/json")
    suspend fun getProjectCategory(): retrofit2.Response<ProjectCategoryData>

    @GET("/article/list/{index}/json")
    suspend fun getAuthorInfoData(
        @Path("index") index: Int,
        @Query("author") author: String
    ): retrofit2.Response<AuthorResponseData>

    @GET("/wxarticle/chapters/json")
    suspend fun getAuthorNameData(): retrofit2.Response<AuthorNameResponseData>

    @GET("/project/list/{index}/json")
    suspend fun getProjectContentData(
        @Path("index") index: Int,
        @Query("cid") cid: Int // 使用 @Query 明确指定查询参数
    ): retrofit2.Response<ProjectContentResponseData>

    @POST("/user/login")
    suspend fun login(
        @Query("username") username: String,
        @Query("password") password: String
    ): retrofit2.Response<UserResponseData>

    @POST("/user/register")
    suspend fun register(
        @Query("username") username: String,
        @Query("password") password: String,
        @Query("repassword") repassword: String
    ): retrofit2.Response<UserResponseData>

    @GET("/user/logout/json")
    suspend fun logout(): retrofit2.Response<UserResponseData>

    @GET("/lg/collect/list/{index}/json")
    suspend fun getCollectList(
        @Path("index") index: Int
    ): retrofit2.Response<CollectionResponseData>

    @POST("/lg/collect/{index}/json")
    suspend fun collect(
        @Path("index") index: Long
    ): retrofit2.Response<CommenCodeData>

    @POST("/lg/uncollect_originId/{id}/json")
    suspend fun unCollect(
        @Path("id") id: Long
    ): retrofit2.Response<CommenCodeData>

    @POST("/article/query/{index}/json")
    suspend fun search(
        @Path("index") index: Int,
        @Query("k") k: String
    ): retrofit2.Response<SearchResponseData>
}